import request from 'src/axios'

/**
 * @description 分页查询多数据源
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const pageDatasource = (params: object) => {
  return request.get('/other/datasource/page', { params })
}

/**
 * @description 查看数据源
 * @param { String } id 角色主键
 * @returns Promise
 */
export const viewDatasource = (id: string) => {
  return request.get('/other/datasource', { params: { id } })
}

/**
 * @description 新增数据源
 * @param { Object } data 新增数据
 * @returns Promise
 */
export const saveDatasource = (data: object) => {
  return request.post('/other/datasource', data)
}

/**
 * @description 修改数据源
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateDatasource = (data: object) => {
  return request.put('/other/datasource', data)
}

/**
 * @description 删除数据源
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const deleteDatasource = (ids: Array<string>) => {
  return request.delete('/other/datasource', { data: ids })
}

/**
 * @description 启用数据源
 * @param { String } id 主键
 * @returns Promise
 */
export const enableDatasource = (id: string) => {
  return request.put('/other/datasource/enable', { id })
}

/**
 * @description 禁用数据源
 * @param { String } id 主键
 * @returns Promise
 */
export const disableDatasource = (id: string) => {
  return request.put('/other/datasource/disable', { id })
}
